***** Partisan Media Effects Beyond One-Shot Experimental Designs *****
****** Searles et al. - Political Science Research and Methods *******
*********** Replication Data File - December 15, 2020 ****************
set more off

cd "/Users/jdarr/Dropbox/Research/PCRG Portal/Searles - HMP/PSRM/PSRM Revision/Replication"

* Start log file *
log using psrm_searles_et_al

*** Analyses Presented in Manuscript: Figures 2 and 3 ***

use "HMP_analysis_wide.dta", clear

* Descriptives for later in paper *
tabstat fox_fair1, by(dem_dum_pre)
tabstat msnbc_fair1, by(dem_dum_pre)


* Tests of H1: Same as it ever was *
reg fox_fair2 dem_dum_pre fox_fair1 lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog problemFactor stateNewsAdded if partisanNewsFactor==0
est store foxfair_lag

reg msnbc_fair2 rep_dum_pre msnbc_fair1 lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog problemFactor stateNewsAdded if partisanNewsFactor==0
est store msnbcfair_lag


* Create Figure for "Same as it ever was" hypothesis *
coefplot (foxfair_lag, label(Fox News fairness) msize(small) mcolor(black) ciopts(lcolor(black)) offset(0)) (msnbcfair_lag, label(MSNBC fairness) msize(small) ciopts(lcolor(gray)) offset(0)), vertical /*
	*/ title("H1: Same as it ever was" "[No partisan news condition]", orientation(horizontal)) xlabel(,labsize(medium)) ytitle("Out-party" "media" "fairness" "rating", orientation(horizontal))/*
	*/ keep(dem_dum_pre rep_dum_pre) /*
	*/ yscale(range(-1.1 1.1)) ylabel(-1(0.5)1) graphregion(color(white)) plotregion(color(white)) bgcolor(white) msize(small) mcolor(gray) yline(0)/*
	*/ coeflabels(rep_dum_pre = "Rep. rating of MSNBC" dem_dum_pre = "Dem. rating of Fox News", wrap(10)) legend(off) scheme(s2mono)

graph save "Figures/Figure2_H1.gph", replace
graph export "Figures/Figure2_H1.pdf", replace



*** Fixed Effects Analyses: H2 & H3 ***
use "HMP_analysis_long.dta", clear

xtset wave

* Create clone variable for coefplot *
gen C_partisanNewsFactor = partisanNewsFactor

** Create Tables for Appendix **
xtreg fox_fair i.dem_dum_pre##i.C_partisanNewsFactor i.problemFactor##i.C_partisanNewsFactor i.stateNewsAdded##i.C_partisanNewsFactor usageLog
est store foxfair

xtreg msnbc_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor usageLog
est store msnbcfair

* Coefficient plot for H2 *
coefplot (foxfair, label(Fox News fairness) msize(small) mcolor(black) ciopts(lcolor(black)) offset(0)) (msnbcfair, label(MSNBC fairness) msize(small) ciopts(lcolor(gray)) offset(0)), vertical /*
	*/ title("H2: Learning from the enemy" "[Out-party media condition]") xlabel(,labsize(medium)) ytitle("Out-party" "media" "fairness" "rating", orientation(horizontal))/*
	*/ keep(1.dem_dum_pre#1.C_partisanNewsFactor 2.partisanNewsFactor) /*
	*/ yscale(range(-1.1 1.1)) ylabel(-1(0.5)1) graphregion(color(white)) plotregion(color(white)) bgcolor(white) msize(small) mcolor(gray) yline(0)/*
	*/ coeflabels(2.partisanNewsFactor = "Rep. rating of MSNBC" 1.dem_dum_pre#1.C_partisanNewsFactor = "Dem. rating of Fox News", wrap(10)) legend(off) scheme(s2mono)

graph save "Figures/H2.gph", replace
graph export "Figures/H2.pdf", replace


* Coefficient plot for H3 *
coefplot (foxfair, label(Fox News fairness) msize(small) mcolor(black) ciopts(lcolor(black)) offset(0)) (msnbcfair, label(MSNBC fairness) msize(small) ciopts(lcolor(gray)) offset(0)), vertical /*
	*/ title("H3: Familiarity breeds contempt" "[In-party media condition]") xlabel(,labsize(medium)) ytitle("In-party" "media" "fairness" "rating", orientation(horizontal))/*
	*/ keep(1.dem_dum_pre#2.partisanNewsFactor 1.C_partisanNewsFactor) /*
	*/ yscale(range(-1.1 1.1)) ylabel(-1(0.5)1) graphregion(color(white)) plotregion(color(white)) bgcolor(white) msize(small) mcolor(gray) yline(0)/*
	*/ coeflabels(1.C_partisanNewsFactor = "Rep. rating of Fox News" 1.dem_dum_pre#2.partisanNewsFactor = "Dem. rating of MSNBC", wrap(10)) legend(off) scheme(s2mono)

graph save "Figures/H3.gph", replace
graph export "Figures/H3.pdf", replace


* Create Figure 3: combined figure for H2 and H3 *
graph combine "Figures/H2.gph" "Figures/H3.gph", xsize(6) ysize(3.5) row(1) graphregion(color(white))

graph save "Figures/Figure3_H2_H3_combined.gph", replace
graph export "Figures/Figure3_H2_H3_combined.pdf", replace






**** Appendix Analyses ****

**** Appendix A ****

*** Table A1: Top 27 News Outlets included in News Portal ***
clear
import excel using "portalpanel16_sources.xlsx", firstrow case(lower)
keep if storycount > 100

* Copy resulting dataset to Word to replicate Table A1 *


*** Table A2: ANOVA for headlines and clicks, by partisan news conditions ***
use "HMP_analysis_wide.dta", clear

tab partisanNewsFactor,sum (partisanhits)
anova partisanhits i.partisanNewsFactor
oneway partisanhits partisanNewsFactor,bonferroni 


tab partisanNewsFactor,sum (partisanclicks)
anova partisanclicks i.partisanNewsFactor
oneway partisanclicks partisanNewsFactor,bonferroni 


*** Table A3: H1 analyses (Figure 2) ***
use "HMP_analysis_wide.dta", clear

reg fox_fair2 dem_dum_pre fox_fair1 lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog problemFactor stateNewsAdded if partisanNewsFactor==0
outreg2 using "Tables/A3_Lagged_H1.doc", se dec(3)

reg msnbc_fair2 rep_dum_pre msnbc_fair1 lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog problemFactor stateNewsAdded if partisanNewsFactor==0
outreg2 using "Tables/A3_Lagged_H1.doc", se dec(3)


*** Table A4: H2 and H3 analyses (Figure 3) ***
use "HMP_analysis_long.dta", clear
xtset wave

* Create clone variable for coefplot *
gen C_partisanNewsFactor = partisanNewsFactor

** Create Tables for Appendix **
xtreg fox_fair i.dem_dum_pre##i.C_partisanNewsFactor i.problemFactor##i.C_partisanNewsFactor i.stateNewsAdded##i.C_partisanNewsFactor usageLog
est store foxfair
outreg2 using "Tables/A4_Analysis_int_only.doc", se dec(3)

xtreg msnbc_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor usageLog
est store msnbcfair
outreg2 using "Tables/A4_Analysis_int_only.doc", se dec(3)


*** Table A5: H2 and H3 analyses with control variables ***
xtreg fox_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog
outreg2 using "Tables/A5_Analysis_covars.doc", se dec(3)

xtreg msnbc_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog
outreg2 using "Tables/A5_Analysis_covars.doc", se dec(3)



*** Table A6: H1 Analyses with Index ***
use "HMP_analysis_wide.dta", clear

reg fox_index2 dem_dum_pre fox_index1 lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog problemFactor stateNewsAdded if partisanNewsFactor==0
est store foxindex_lag

outreg2 using "Tables/A6_index_Lagged_H1.doc", se dec(3)


reg msnbc_index2 rep_dum_pre msnbc_index1 lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog problemFactor stateNewsAdded if partisanNewsFactor==0
est store msnbcindex_lag
outreg2 using "Tables/A6_index_Lagged_H1.doc", se dec(3)


*** Figure A1: for "Same as it ever was" hypothesis with index ***
coefplot (foxindex_lag, label(Fox News index) msize(small) mcolor(black) ciopts(lcolor(black)) offset(0)) (msnbcindex_lag, label(MSNBC index) msize(small) ciopts(lcolor(gray)) offset(0)), vertical /*
	*/ title("H1: Same as it ever was" "[No partisan news condition]", orientation(horizontal)) xlabel(,labsize(medium)) ytitle("Out-party" "media" "index" "rating", orientation(horizontal))/*
	*/ keep(dem_dum_pre rep_dum_pre) /*
	*/ yscale(range(-3.1 3.1)) ylabel(-3(1)3) graphregion(color(white)) plotregion(color(white)) bgcolor(white) msize(small) mcolor(gray) yline(0)/*
	*/ coeflabels(rep_dum_pre = "Rep. rating of MSNBC" dem_dum_pre = "Dem. rating of Fox News", wrap(10)) legend(off) scheme(s2mono)

graph save "Figures/A1_index_H1.gph", replace
graph export "Figures/A1_index_H1.pdf", replace


*** Table A7: Fixed Effects Analyses: H2 & H3 ***
use "HMP_analysis_long.dta", clear
xtset wave

* Create clone variable for coefplot *
gen C_partisanNewsFactor = partisanNewsFactor

xtreg fox_index i.dem_dum_pre##i.C_partisanNewsFactor i.problemFactor##i.C_partisanNewsFactor i.stateNewsAdded##i.C_partisanNewsFactor usageLog
est store foxindex
outreg2 using "Tables/A7_index_Analysis_int_only.doc", se dec(3)

xtreg msnbc_index i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor usageLog
est store msnbcindex
outreg2 using "Tables/A7_index_Analysis_int_only.doc", se dec(3)


*** Figure A2: Coefficient plot for H2 & H3 using index *
coefplot (foxindex, label(Fox News index) msize(small) mcolor(black) ciopts(lcolor(black)) offset(0)) (msnbcindex, label(MSNBC index) msize(small) ciopts(lcolor(gray)) offset(0)), vertical /*
	*/ title("H2: Learning from the enemy" "[Out-party media condition]") xlabel(,labsize(medium)) ytitle("Out-party" "media" "index" "rating", orientation(horizontal))/*
	*/ keep(1.dem_dum_pre#1.C_partisanNewsFactor 2.partisanNewsFactor) /*
	*/ yscale(range(-3.1 3.1)) ylabel(-3(1)3) graphregion(color(white)) plotregion(color(white)) bgcolor(white) msize(small) mcolor(gray) yline(0)/*
	*/ coeflabels(2.partisanNewsFactor = "Rep. rating of MSNBC" 1.dem_dum_pre#1.C_partisanNewsFactor = "Dem. rating of Fox News", wrap(10)) legend(off) scheme(s2mono)

graph save "Figures/index_H2.gph", replace
graph export "Figures/index_H2.pdf", replace


* Coefficient plot for H3 *
coefplot (foxindex, label(Fox News index) msize(small) mcolor(black) ciopts(lcolor(black)) offset(0)) (msnbcindex, label(MSNBC index) msize(small) ciopts(lcolor(gray)) offset(0)), vertical /*
	*/ title("H3: Familiarity breeds contempt" "[In-party media condition]") xlabel(,labsize(medium)) ytitle("In-party" "media" "index" "rating", orientation(horizontal))/*
	*/ keep(1.dem_dum_pre#2.partisanNewsFactor 1.C_partisanNewsFactor) /*
	*/ yscale(range(-3.1 3.1)) ylabel(-3(1)3) graphregion(color(white)) plotregion(color(white)) bgcolor(white) msize(small) mcolor(gray) yline(0)/*
	*/ coeflabels(1.C_partisanNewsFactor = "Rep. rating of Fox News" 1.dem_dum_pre#2.partisanNewsFactor = "Dem. rating of MSNBC", wrap(10)) legend(off) scheme(s2mono)

graph save "Figures/index_H3.gph", replace
graph export "Figures/index_H3.pdf", replace


* Create combined Figure A2 for H2 and H3 *
graph combine "Figures/index_H2.gph" "Figures/index_H3.gph", xsize(6) ysize(3.5) row(1) graphregion(color(white))

graph save "Figures/A2_index_H2_H3_combined.gph", replace
graph export "Figures/A2_index_H2_H3_combined.pdf", replace


*** Table A8: H2 and H3 analyses including individual-level covariates ***
xtreg fox_index i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog
outreg2 using "Tables/A8_index_Analysis_covars.doc", se dec(3)

xtreg msnbc_index i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor lgage female white collegeGradDum lgideology_pre lgpolInterest_pre usageLog
outreg2 using "Tables/A8_index_Analysis_covars.doc", se dec(3)



**** Appendix B ****
use "HMP_analysis_wide.dta", clear

* Descriptives *
tab wave2
tab wave3

* Table B1. Attrition by Experimental Treatment *
firthlogit wave2 i.partisanNewsFactor i.problemFactor i.stateNewsAdded
outreg2 using "Tables/B1_attrition.doc", se dec(3)
firthlogit wave3 i.partisanNewsFactor i.problemFactor i.stateNewsAdded
outreg2 using "Tables/B1_attrition.doc", se dec(3)

* Table B2. Attrition by Experimental Treatment and Partisanship *
firthlogit wave2 i.dem_dum_pre##i.partisanNewsFactor i.problemFactor i.stateNewsAdded
outreg2 using "Tables/B2_attrition_party.doc", se dec(3)
firthlogit wave3 i.dem_dum_pre##i.partisanNewsFactor i.problemFactor i.stateNewsAdded
outreg2 using "Tables/B2_attrition_party.doc", se dec(3)

* Table B3. Attrition by Experimental Treatment, Partisanship and Demographic Characteristics *
firthlogit wave2 i.dem_dum_pre##i.partisanNewsFactor i.problemFactor i.stateNewsAdded lgage i.female i.white i.collegeGradDum lgideology_pre lgpolInterest_pre
outreg2 using "Tables/B3_attrition_party_covars.doc", se dec(3)
firthlogit wave3 i.dem_dum_pre##i.partisanNewsFactor i.problemFactor i.stateNewsAdded lgage i.female i.white i.collegeGradDum lgideology_pre lgpolInterest_pre
outreg2 using "Tables/B3_attrition_party_covars.doc", se dec(3)


* Attrition as a factor for waves 2 and 3 *
use "HMP_analysis_long.dta", clear
xtset wave

* Table B4. Perceptions of Fox News Fairness, Using Wave 3 Participants Only. Random Effects Estimator. *
xtreg fox_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor if subjectid_3 != .
outreg2 using "Tables/B4_wave3_fox.doc", se dec(3)
xtreg fox_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor lgage i.female i.white i.collegeGradDum lgideology_pre lgpolInterest_pre usageLog if subjectid_3 != .
outreg2 using "Tables/B4_wave3_fox.doc", se dec(3)

* Table B5. Perceptions of MSNBC Fairness, Using Wave 3 Participants Only. Random Effects Estimator. *
xtreg msnbc_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor if subjectid_3 != .
outreg2 using "Tables/B5_wave3_msnbc.doc", se dec(3)
xtreg msnbc_fair i.dem_dum_pre##i.partisanNewsFactor i.problemFactor##i.partisanNewsFactor i.stateNewsAdded##i.partisanNewsFactor lgage i.female i.white i.collegeGradDum lgideology_pre lgpolInterest_pre usageLog if subjectid_3 != .
outreg2 using "Tables/B5_wave3_msnbc.doc", se dec(3)




**** Appendix C ****
use "HMP_analysis_long.dta", clear
xtset wave

* Table C1. Perceptions of Fox News Fairness, by News Portal Usage (three-way interaction) *
xtreg fox_fair i.dem_dum_pre##i.partisanNewsFactor##i.usageScoreDum i.problemFactor i.stateNewsAdded
outreg2 using "Tables/C1_usage_fox.doc", se dec(3)

* Table C2. Perceptions of MSNBC Fairness, by News Portal Usage (three-way interaction) *
xtreg msnbc_fair i.dem_dum_pre##i.partisanNewsFactor##i.usageScoreDum i.problemFactor i.stateNewsAdded
outreg2 using "Tables/C2_usage_msnbc.doc", se dec(3)




**** Appendix D ****
use "HMP_analysis_long.dta", clear
xtset wave

* Table D1. Perceptions of Fox News Fairness. Random Effects Estimator. Model Includes Experimental Conditions without Interactions *
xtreg fox_fair i.dem_dum_pre i.partisanNewsFactor i.problemFactor stateNewsAdded
outreg2 using "Tables/D1_noint_fox.doc", se dec(3)
xtreg fox_fair i.dem_dum_pre i.partisanNewsFactor i.problemFactor stateNewsAdded lgage i.female i.white i.collegeGradDum lgideology_pre lgpolInterest_pre usageLog
outreg2 using "Tables/D1_noint_fox.doc", se dec(3)

* Table D2. Perceptions of MSNBC News Fairness. Random Effects Estimator. Model Includes Experimental Conditions without Interactions *
xtreg msnbc_fair i.dem_dum_pre i.partisanNewsFactor i.problemFactor stateNewsAdded
outreg2 using "Tables/D2_noint_msnbc.doc", se dec(3)
xtreg msnbc_fair i.dem_dum_pre i.partisanNewsFactor i.problemFactor stateNewsAdded lgage i.female i.white i.collegeGradDum lgideology_pre lgpolInterest_pre usageLog
outreg2 using "Tables/D2_noint_msnbc.doc", se dec(3)


* End log file *
log close
